<div class="operateBox">	
  <div id="l_toolbar"></div> 
  <h2><?php echo $this->title?></h2>

  <form class="search" method="post" action="">
	<span class="s-field"><input size="28" type="search" name="s[name]" value="<?php e_h($s['name'])?>" placeholder="订单、商品名" /></span>
    <span class="s-field"><?php html::select(' name="s[state]"', $state, $s['state'], lang::g('select state'))?></span>
    <span class="s-field"><label>下单时间</label><input type="text" name="s[timeS]"  value="<?php e_h($s['timeS'])?>" size="10" onClick="WdatePicker()" />-<input type="text" name="s[timeE]"  value="<?php e_h($s['timeE'])?>" size="10" onClick="WdatePicker()" /></span>
    <input type="submit" class="sb" value="筛选" /> 
</form>
</div>    


<table width="100%" class="ta-h" id="dataList">
  <tbody>
    <?php foreach($res as $v){?>
    <tr class="shop-order" i_ID="<?php echo $v['id']?>" class="sl-i">
      <th>订单：<?php echo $v['sn']?></th>
      <th width="209"><?php echo $v['time']?></th>
      <th width="100"><?php echo $v['userName']?></th>
      <th width="120"><?php echo $state[$v['state']];?></th>
    </tr>
    <tr i_ID="<?php echo $v['id']?>" class="sl-i">
      <td colspan="2" class="has-sub-ta">
        <table width="100%" class="sub-ta"><tbody>
          <?php foreach($detailR[$v['id']] as $g){?>
          <tr>
            <td width="100"><img width="100" height="80" src="<?php e_qh($g['pic'])?>" /></td>
            <td><a href="<?php echo url::g('u=cgoods\v&id='. $g['goods_id'])?>" target="_blank"><?php e_h($g['name'])?></a></td>
            <td width="200" align="center"><p><?php echo $g['money']?></p><p>x <?php echo $g['num']?></p></td>
          </tr>
          <?php }?></tbody>
        </table>
      </td>
      
      <td>
	    <?php 
			echo '总金额：'. $v['money'] .'<br />';
			echo '实支付：'. $v['pay_money'] .'<br />';
			e_h($v['pay_way']);
		?>
      </td>
      <td align="center">
      	<a onClick="dTA.viewRow()">订单查看</a><br />
		<?php if($v['state']==2){?><a onClick="SG(this)">发货</a><?php }else{?>
        <a onClick="edit(this)">修改</a><?php }?>
      </td>
    </tr>
    <?php }?>
  </tbody>
</table>
<?php $this->loadTemplate('paging');?>


<form class="post-col none" id="fh_post">
 <div class="sh">快递公司：</div><div class="sp"><input type="text" name="expre_name" id="expre_name" /><input type="hidden" name="expre_id" id="expre_id" /></div>
 <div class="sh">运单号码：</div><div class="sp"><input type="text" name="expre_code" /></div>
 <p><button class="submit" type="button">提交</button></p></form>

<style>
.ta-h tr{background-color:#fff !important}
</style>
<script>
var dTA = Table_Ad.init('#dataList',{u_view: '?u=cshop\\order\\a-fview&id=', u_del: '?u=cshop\\order\\a-fdel&id='});

//fh
var fh_eli=SearchWordAC('#expre_name', ROOT_URL +'?u=cexpress\\g-fsearchWord&w=');
fh_eli.setLiFun = function(li, d){ $(li).text(d.name);}
fh_eli.selectFun = function(li, d){
	$('#expre_id').val(d.id);
	$('#expre_name').val(d.name);
	$(this.l).slideUp();
};
var fh_postD = setPoDIV('#fh_post',{l:-210});
function SG(t){
	fh_postD.show(t);
	var id = dTA.getRowID(t), f = $('#fh_post');
	
	f[0].reset();
	$('#expre_id').val(0);
	f.find('button').click(function(){
		$.post('?u=cshop\\order\\a-fsendGoods&id='+ id, f.serialize(), function(r){if(checAjaxRe(r)){
			f.hide();
			$(t).hide().parent().append('<a onClick="edit(this)">修改</a>');
		}});
	});
}

// edit
function edit(o){
	var id = dTA.getRowID(o);
	$.get('?u=cshop\\order\\a-fedit&id='+ id,function(r){
		var bo = box(r, '修改', {align:'left'});
		bo.txt.find('button').click(function(){
			$.post('?u=cshop\\order\\a-fedit&id=' + id, bo.txt.find('form').serialize(), function(r){if(checAjaxRe(r)){
				bo.close();
			}});
		});
	});
}
</script>